package org.jeecg.modules.product.contractor.service.impl;

import org.jeecg.modules.product.contractor.entity.TbContractor;
import org.jeecg.modules.product.contractor.mapper.TbContractorAptitudeMapper;
import org.jeecg.modules.product.contractor.mapper.TbContractorBusinessLicenseMapper;
import org.jeecg.modules.product.contractor.mapper.TbContractorMapper;
import org.jeecg.modules.product.contractor.mapper.TbContractorSafetyPermitMapper;
import org.jeecg.modules.product.contractor.service.ITbContractorService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 承包商信息
 * @Author: jeecg-boot
 * @Date:   2024-07-08
 * @Version: V1.0
 */
@Service
public class TbContractorServiceImpl extends ServiceImpl<TbContractorMapper, TbContractor> implements ITbContractorService {

	@Autowired
	private TbContractorMapper tbContractorMapper;
	@Autowired
	private TbContractorSafetyPermitMapper tbContractorSafetyPermitMapper;
	@Autowired
	private TbContractorBusinessLicenseMapper tbContractorBusinessLicenseMapper;
	@Autowired
	private TbContractorAptitudeMapper tbContractorAptitudeMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		tbContractorSafetyPermitMapper.deleteByMainId(id);
		tbContractorBusinessLicenseMapper.deleteByMainId(id);
		tbContractorAptitudeMapper.deleteByMainId(id);
		tbContractorMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			tbContractorSafetyPermitMapper.deleteByMainId(id.toString());
			tbContractorBusinessLicenseMapper.deleteByMainId(id.toString());
			tbContractorAptitudeMapper.deleteByMainId(id.toString());
			tbContractorMapper.deleteById(id);
		}
	}
	
}
